package com.cfm880.tut1;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * Created by chengfangming on 2017/5/24.
 */
public class Tut1Sender {
    @Autowired
    private RabbitTemplate template;

    @Autowired
    private Queue queue;


    @Scheduled(fixedDelay = 1000, initialDelay = 5000)
    public void send(){
        String message = "Hello world!";
        this.template.convertAndSend(queue.getName(), message);

        System.out.println(" X sent "+ message + "");
    }
}
